<?php 
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system 
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : attribute_content.class.php   FILE_PATH : E:\www\\trunk\classes\application\attribute_content.class.php
 * .... 商品属性内容操作类
 *
 * @copyright workflow_system 
 * @author workflow Develop Team 
 * @package 
 * @subpackage 
 * @version Mon Jun 23 22:04:46 CST 2008
 */
defined('Base_Use_Sign') or die("this is invalid system!please contact <a href='http://www.shopnc.net'>www.shopnc.net</>.");

class AttributeContentClass extends FrameWork {
	/**
	 * 获得商品分类属性下的内容列表
	 *
	 * @param int $a_id
	 * @return array $attribute_content_array
	 */
	function getAttributeContentList($obj_condition,&$obj_page){
		$condition_str = $this->_conditionSearch($obj_condition);
		$attribute_content_array = $GLOBALS['db']->GetList($condition_str, $obj_page, "attribute_content");
		return $attribute_content_array;
	}
	/**
	 * 获得商品分类属性下的内容
	 *
	 * @param unknown_type $ac_id
	 * @return unknown
	 */
	function getAttributeContentRow($ac_id){
		if (intval($ac_id) > 0){
			$attribute_content_row = $GLOBALS['db']->GetOneRow($ac_id,'attribute_content','ac_id');
			return $attribute_content_row;
		}else {
			return false;
		}
	}
	/**
	 * 添加商品属性内容
	 *
	 * @param array $input
	 * @return boolen
	 */
	function addAttributeContent($input){
		$valueArray = array();
		$valueArray["a_id"]	= $input["aid"];
		$valueArray["ac_content"]	= $input["accontent"];
		$valueArray["ac_order"]	= $input["acorder"];
		$insert_rs = $GLOBALS['db']->InsertRow($valueArray, 'attribute_content', 'ac_id');
		return $insert_rs;
	}
	/**
	 * 更新商品属性内容
	 *
	 * @param array $input
	 * @return boolen
	 */
	function updateAttributeContent($input){
		if (intval($input["acid"]) > 0){
			$valueArray = array();
			$valueArray["ac_content"]	= $input["accontent"];
			$valueArray["ac_order"]	= $input["acorder"];
			$update_rs = $GLOBALS['db']->UpdateRow(intval($input["acid"]), $valueArray, 'attribute_content', 'ac_id');
			return $update_rs;
		}else {
			return false;
		}
	}
	/**
	 * 删除商品属性内容
	 *
	 * @param array $input
	 * @return boolen
	 */
	function delAttributeContent($input){
		if ($input){
			$del_rs = $GLOBALS['db']->DelRow($input, 'attribute_content', 'ac_id');
			return $del_rs;
		}else {
			return false;
		}
	}
	/**
	 * 构造属性检索条件
	 *
	 * @param object $obj_condition 查询条件对象
	 * @return string $conditionStr 返回查询条件SQL字符串
	 */
	function _conditionSearch($condition){
		$conditionStr = "";
		//属性ID
		if ($condition['a_id'] != ''){
			$conditionStr .= " and a_id = '" . $condition['a_id'] . "'";
		}
		//属性内容ID
		if ($condition['ac_id'] != ''){
			$conditionStr .= " and ac_id = '" . $condition['ac_id'] . "'";
		}
		//属性ID范围内
		if ($condition['in_ac_id'] != ''){
			$conditionStr .= " and ac_id in (" . $condition['in_ac_id'] . ")";
		}
		if($condition['order'] == 1){
			$conditionStr .= " order by ac_order desc";
		}else{
			$conditionStr .= " order by ac_order";
		}
		return $conditionStr;
	}
}
?>